home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2509 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.6 KB  |  82 lines

  1. Path: perception.co.nz!simond
  2. From: simond@perception.co.nz (Simon Dawson)
  3. Newsgroups: comp.lang.c
  4. Subject: Malloc failing with Huge Arrays under VC++ 1.0
  5. Message-ID: <pXsAxAWLBh107h@perception.co.nz>
  6. Date: Mon, 22 Jan 96 12:02:01 +1300
  7. Organization: Perception
  8.  
  9. Hi All,
  10.  
  11. ok, panic time here, trying to get huge arrays working under VC++, code works
  12. something like this (2 major arrays):
  13.  
  14. ------------------------------------------ 
  15.  
  16.   //declare position as a huge global array
  17.   unsigned long __huge *position;                                            
  18.  
  19.  
  20.   void main(void)
  21.   {
  22.   
  23.   [snip other minor (nothing big) declarations]
  24.  
  25.  
  26.   //set the maximum numbers we can deal with
  27.   unsigned long MAX_ARRAY_SIZE = 16383;
  28.  
  29.   //malloc the position array - yes, unsigned long is same size as regular long!
  30.   if (!(position = (unsigned long __huge *)malloc(MAX_ARRAY_SIZE * sizeof(unsigned long))) ) return;
  31.     
  32.   //define and malloc the stored values array
  33.   float __huge *array;                                         
  34.   if (!(array = (float __huge *)malloc(MAX_ARRAY_SIZE * sizeof(float))) ) return;
  35.  
  36.  
  37.   [snip code]
  38.  
  39.   }
  40.  
  41.  
  42. The code fails (drops out) when it goes to malloc the position array.  
  43.  
  44. ------------------------------------------ 
  45.  
  46. The Compiler Options are:
  47.  
  48. /nologo /f- /G3 /FPc /Mq /W3 /Zi /AH /Od /D "_DEBUG" /FR /Fd"SORT.PDB"
  49.  
  50. The Linker Options are:
  51. /NOLOGO /LIB:"oldnames" /LIB:"libw" /LIB:"llibcewq" /NOD /NOE /PACKC:57344 
  52. /STACK:16383 /ALIGN:16 /ONERROR:NOEXE /CO 
  53.  
  54. There is no .DEF file, but the stack forces through at 8096 bytes.
  55.  
  56. ------------------------------------------ 
  57.  
  58. I've read the __huge help file till I'm blue, plus the malloc, __far and anything
  59. else I can think of, but nothing seems to point to anything useful.  I'm running
  60. WFW 3.11, on a 486-50, with 20Meg RAM, (40+ with swap), it's a clean start into
  61. windows, with no other apps in the background.
  62.  
  63. So far I can get it to MAX_ARRAY_SIZE just over 10000, but we're not looking at
  64. a useful huge array at that stage.. as soon as I move to this size, it starts
  65. junking.  I'd -like- to be able to run with a 100,000+ size set of arrays.
  66.  
  67. Now it -used- to malloc fine, and then when I went to access later positions in
  68. the array array (eg, just loop through and set each position to 5 - as a test), it 
  69. would GPF on me.  Error message, no debug info, VC++ still running.  No idea what
  70. has changed, but either way, situation seems to be getting worse.
  71.  
  72.  
  73.  
  74. Does anyone have any suggestions that could point me in the right direction to
  75. actually be able to -use- these huge arrays?  If you have anything I could try,
  76. that would be wonderful..
  77.  
  78.  
  79. Thankyou so much,
  80.  
  81. Simon
  82.